package com.nondo.rdp.finance.domain.course;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.nondo.rdp.auth.domain.User;
import com.nondo.rdp.core.domain.base.BaseEntity;
import com.nondo.rdp.finance.config.DbConfig;

/**
 * 求知-课节评论
 */
@Entity
@Table(name = DbConfig.DEFAULT_TABLE_PREFIX + "section_comment")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class SectionComment extends BaseEntity {
	private static final long serialVersionUID = 289766559013081787L;
	private Long id;// 主键
	private Section section;// 课节
	private User user;// 评论用户
	private String body;// 评论内容
	private String authorComment;// 作者回复
	private Date authorCommentDate;//作者回复时间
	private int auditStatus;// 审核0|1|2

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@JsonIgnore
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "sid")
	public Section getSection() {
		return section;
	}

	@JsonSetter
	public void setSection(Section section) {
		this.section = section;
	}

	@OneToOne
	@JoinColumn(name = "uid")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Length(min = 1, max = 255, message = "评论内容长度不能超过255个字符")
	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	@Length(min = 1, max = 255, message = "回复内容长度不能超过255个字符")
	public String getAuthorComment() {
		return authorComment;
	}

	public void setAuthorComment(String authorComment) {
		this.authorComment = authorComment;
	}

	public Date getAuthorCommentDate() {
		return authorCommentDate;
	}

	public void setAuthorCommentDate(Date authorCommentDate) {
		this.authorCommentDate = authorCommentDate;
	}

	@Column(columnDefinition = "int default 0", nullable = false)
	public int getAuditStatus() {
		return auditStatus;
	}

	public void setAuditStatus(int auditStatus) {
		this.auditStatus = auditStatus;
	}

}
